<template>
  <!-- 新款女装 --> 
  <div class="new-product clearfix">
    <div class="new-patterns" v-if="indexFloor.isViewName == '1'">
      <div class="fl">
        <div class="tagI" :style="styleCss(indexFloor)"></div>
        <div class="font-title" v-text="indexFloor.gf_name"></div>
        <div class="font-e-title">{{indexFloor.en_name | toUpperCase}}</div>
      </div>
      <ul class="new-pattern-nav fr">
        <li 
          v-for="(hot, index) in navKeyWords" 
          :key="index" 
          v-text="hot"  
          @click.stop="indexFloorJump('keyWord', hot)">
        </li>
      </ul>
      <div class="clearfix"></div>
    </div>
    <!-- <div class="clearfix"></div> -->
    <div class="new-father" v-if="indexFloor.wide_goods">
      <div class="clearfix" >
        <div class="new-product-content bgc clearfix">
          <div class="new-product-right fl" @click.stop="indexFloorJump(JSON.parse(indexFloor.wide_goods)[0].left.type, JSON.parse(indexFloor.wide_goods)[0].left.value)">
            <div class="list-new">
              <ul class="T-list clearfix">
                <li class="fl" 
                  v-for="(list, index) in keyWords" 
                  :key="index" 
                  v-text="list" 
                  @click.stop="indexFloorJump('keyWord', list)">
                </li>
              </ul>
            </div>
            <img v-lazy="JSON.parse(indexFloor.wide_goods)[0].left.img" class="add-img">
          </div>
          <div class="fl">
            <ul class="new-product-middle">
              <li 
                v-for="(middleGoods, index) in (JSON.parse(indexFloor.wide_goods)[1].middle.goodsList)" 
                :key="index" 
                class="fl" 
                @click.stop="indexFloorJump(middleGoods.type, middleGoods.value)" 
                :style="{ 'border-bottom': `${index % 3 >= 1 ? '1px solid #f6f6f6' : '0px' }`}">
                  <div class="content-s-p">
                    <div class="pic-img">
                      <img v-lazy="middleGoods.img" class="imgs-d middle-imgs transition-ease">
                    </div>
                    <div v-text="middleGoods.titleName"></div>
                  </div>
              </li>
            </ul>
          </div>
          <div class="new-product-left fl">
            <p class="today-hot" v-text="JSON.parse(indexFloor.wide_goods)[2].right.title.titleName" v-if="JSON.parse(indexFloor.wide_goods)[2].right.title.titleName"></p>
            <p class="today-hot-en" v-text="JSON.parse(indexFloor.wide_goods)[2].right.title.enName" v-if="JSON.parse(indexFloor.wide_goods)[2].right.title.enName"></p>
            <w-banner :lists="JSON.parse(indexFloor.wide_goods)[2].right.goodsList" :height="514"></w-banner>   
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      indexFloor: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    computed: {
      // 判断关键字
      keyWords() {
        let arr = JSON.parse(this.indexFloor.wide_goods)[0].left.keyWord
        if (arr) {
          return arr.slice(1, arr.length - 1).split(',')
        }
      },
      // 判断关键字
      navKeyWords() {
        if (this.indexFloor.keyWord) {
          return this.indexFloor.keyWord.split(',')
        }
      }
    },
    methods: {
      // 跳转对应页面(商品详情或者搜索页面)
      indexFloorJump(type, id, index) {
        if (index != 0 && index) {
          return
        }
        switch (type) {
          case 'goodsInfo': // 进入商品详情
            window.open('/goods/detail/' + id)
            break
          case 'channel': // 频道
            this.$emit('on-floor-channel', id)
            break
          case 'store': // 进入店铺
            this.intoStore(id)
            break
          case 'link': // 进入链接
            window.open(id.replace('/#', ''))
            break
          case 'goodsList': // 进入商品列表
            sessionStorage.setItem('goodsIds', id)
            window.open('/search/goodsLists')
            break
          case 'storeSearch':
            window.open(`/search/stores?type=stores&st=2&key=${decodeURIComponent(encodeURIComponent(id))}`)
            break
          default:
            if (type == 'brandSearch') {
              window.open(`/search/goods?type=goods&st=3&name=${decodeURIComponent(encodeURIComponent(id))}&ob=`)
            } else {
              window.open(`/search/goods?type=goods&st=1&key=${decodeURIComponent(encodeURIComponent(id))}&ob=`)
            }
        }
      },
      // 进入对应商家店铺
      intoStore(id) {
        window.open('/shop/' + id)
      },
      /**
       * css样式
       */
      styleCss(indexFloor) {
        return {'border': '2px solid #' + indexFloor.gf_css}
      }
    },
    filters: {
      /**
       * 大写
       */
      toUpperCase(val) {
        if (val) {
          return val.toUpperCase()
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
</style>